
Object.defineProperty(exports, "__esModule", { value: true });
/**
* @module im.session
* @author: Hjava
* @description: IM模块消息外包
* @since: 2018-07-22 14:51:33
*/
var im_constant_1 = __webpack_require__(/*! _im/im.constant */ "./src/core/im/im.constant.ts");
var bufferType_1 = __webpack_require__(/*! _util/bufferType */ "./src/core/utils/bufferType.ts");
var constant_1 = __webpack_require__(/*! _util/constant */ "./src/core/utils/constant.ts");
var deviceInfo_1 = __webpack_require__(/*! _util/deviceInfo */ "./src/core/utils/deviceInfo.ts");
var protocol_1 = __webpack_require__(/*! _util/protocol */ "./src/core/utils/protocol.ts");
var timer_1 = __webpack_require__(/*! _util/timer */ "./src/core/utils/timer.ts");
var userData_1 = __webpack_require__(/*! _util/userData */ "./src/core/utils/userData.ts");
var uuid_1 = __webpack_require__(/*! _util/uuid */ "./src/core/utils/uuid.ts");
var IMSession = {};
IMSession.IMSendGroupMsgReq = protocol_1.default.Response.extend({
    category: 'IM',
    uri: im_constant_1.default.IM.URI_IM_SEND_GROUP_MSG,
    init: function () {
        this.uri = im_constant_1.default.IM.URI_IM_SEND_GROUP_MSG;
        //设备类型
        this.deviceType = deviceInfo_1.default.deviceType;
        //客户端消息ID
        this.msgUuid = uuid_1.default.next();
        //发送人UID
        this.fromUid = 0;
        //接收群UID
        this.toGuid = 0;
        //消息类型
        this.type;
        //消息内容
        this.message;
        // 发送人名称//nickname
        this.fromName = '';
        // 群组名称
        this.groupName = '';
        // 消息产生时间
        this.cts = timer_1.default.get();
        this.msgId = '';
        // 扩展信息
        this.extension = '';
        // 序列id
        this.seqId = 0;
        this.retries = 0; //自动重发次数
        this.clusterId = ''; //集群id
        this.receipt = 0; //回执消息
        this.channel = 0;
        this.sessionSeqId = '';
        this.compatible = '';
        this.deviceId = userData_1.default.get('deviceId');
        this.messageReceivedType = constant_1.MESSAGE_RECEIVED_TYPE.GROUP_MESSAGE;
        this.fromPubId = '';
        this.fromPubName = '';
        this.msgSourceType = 0;
        this.receiveUids = [];
    },
    setUid: function (uid) {
        this.fromUid = uid;
    },
    initAfter: function () {
        this.message && (this.type = this.type || this.message.__type);
    },
    marshall: function () {
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.msgUuid); //客户端消息ID
        this.push(this.fromUid, bufferType_1.default.LONG);
        this.push(this.toGuid, bufferType_1.default.LONG);
        this.push(this.type); //消息类型
        this.push(this.message);
        this.push(this.fromName);
        this.push(this.groupName);
        this.push(this.cts, bufferType_1.default.LONG);
        this.push(this.msgId, bufferType_1.default.LONG);
        this.push(this.extension);
        this.push(this.seqId, bufferType_1.default.LONG);
        this.push(this.retries, bufferType_1.default.BYTE);
        this.push(this.clusterId, bufferType_1.default.INT);
        this.push(this.receipt, bufferType_1.default.BYTE);
        this.push(this.channel, bufferType_1.default.SHORT);
        this.push(this.sessionSeqId, bufferType_1.default.LONG);
        this.push(this.compatible, bufferType_1.default.STRING);
        this.push(this.deviceId, bufferType_1.default.STRING);
        this.push(this.fromPubId, bufferType_1.default.LONG);
        this.push(this.fromPubName, bufferType_1.default.STRING);
        this.push(this.msgSourceType, bufferType_1.default.BYTE);
        this.push(this.receiveUids, bufferType_1.default.ARRAY_LONG);
    },
    unmarshall: function () {
        this.deviceType = this.popByte();
        this.msgUuid = this.popString();
        this.fromUid = this.popLong().value();
        this.toGuid = this.popLong().value();
        this.type = this.popInt();
        this.message = protocol_1.default.Message.fromBuffer(this.popBytes());
        this.fromName = this.popString();
        this.groupName = this.popString();
        this.cts = this.popLong().value();
        this.msgId = this.popLong();
        this.extension = this.popString();
        this.seqId = this.popLong().value();
        this.retries = this.popByte();
        this.clusterId = this.popInt();
        this.receipt = this.popByte();
        this.channel = this.popShort();
        this.sessionSeqId = this.popLong().value();
        this.compatible = this.popString();
        this.deviceId = this.popString();
        this.fromPubId = this.popLong().value();
        this.fromPubName = this.popString();
        this.msgSourceType = this.popByte();
        this.receiveUids = this._popArrayLong();
    }
});
/**
 * 服务器端消息Res (服务器的Ack)
 * @type {Function}
 */
IMSession.IMSendGroupMsgRes = protocol_1.default.Response.extend({
    category: 'IM',
    uri: im_constant_1.default.IM.URI_IM_SEND_GROUP_MSG_RES,
    init: function () {
        this.msgUuid = '';
        this.msgId = '';
        this.cts = 0;
        this.rescode = 0;
        this.deviceType = 0;
        this.seqId = 0;
        this.clusterId = 0;
        this.sessionSeqId = '';
    },
    marshall: function () {
        this.push(this.msgUuid, bufferType_1.default.STRING);
        this.push(this.msgId, bufferType_1.default.LONG);
        this.push(this.cts, bufferType_1.default.LONG);
        this.push(this.rescode, bufferType_1.default.INT);
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.seqId, bufferType_1.default.LONG);
        this.push(this.clusterId, bufferType_1.default.INT);
        this.push(this.sessionSeqId, bufferType_1.default.LONG);
    },
    unmarshall: function () {
        this.msgUuid = this.popString();
        this.msgId = this.popLong().value();
        this.cts = this.popLong().value();
        this.rescode = this.popInt();
        this.deviceType = this.popByte();
        this.seqId = this.popLong().value();
        this.clusterId = this.popInt();
        this.sessionSeqId = this.popLong().value();
    }
});
/**
 * 服务器端群通知
 * @type {Function}
 */
IMSession.IMGroupNotice = protocol_1.default.Response.extend({
    category: 'IM',
    uri: im_constant_1.default.IM.URI_IM_GROUP_NOTICE,
    init: function () {
        this.uri = im_constant_1.default.IM.URI_IM_GROUP_NOTICE;
        //接收群UID
        this.toGuid = 0;
        //更新类型
        this.type = 0;
        //更新内容
        this.data = '';
        this.cts = timer_1.default.get();
        this.channel = '';
    },
    marshall: function () {
        this.push(this.toGuid, bufferType_1.default.LONG);
        this.push(this.type);
        this.push(this.data);
        this.push(this.cts, bufferType_1.default.LONG);
        this.push(this.channel, bufferType_1.default.SHORT);
    },
    unmarshall: function () {
        this.toGuid = this.popLong().value();
        this.type = this.popInt();
        this.data = this.popString();
        this.cts = this.popLong().value();
        this.channel = this.popShort();
    }
});
/**
 * 服务器端加好友通知
 * @type {Function}
 */
IMSession.IMChatNotice = protocol_1.default.Response.extend({
    category: 'IM',
    uri: im_constant_1.default.IM.URI_IM_CHAT_NOTICE,
    init: function () {
        this.uri = im_constant_1.default.IM.URI_IM_CHAT_NOTICE;
        //接收人UID
        this.toUid = 0;
        //更新类型
        this.type = 0;
        //更新内容
        this.data = '';
        this.cts = timer_1.default.get();
    },
    marshall: function () {
        this.push(this.toUid, bufferType_1.default.LONG);
        this.push(this.type);
        this.push(this.data);
        this.push(this.cts, bufferType_1.default.LONG);
    },
    unmarshall: function () {
        this.toUid = this.popLong().value();
        this.type = this.popInt();
        this.data = this.popString();
        this.cts = this.popLong().value();
    }
});
/**
 * 服务器端消息Req
 * @type {Function}
 */
IMSession.IMSendMsgReq = protocol_1.default.Response.extend({
    category: 'IM',
    uri: im_constant_1.default.IM.URI_IM_SEND_MSG,
    init: function () {
        this.uri = im_constant_1.default.IM.URI_IM_SEND_MSG;
        this.deviceType = deviceInfo_1.default.deviceType;
        this.msgUuid = uuid_1.default.next();
        this.fromUid = 0;
        this.toUid = 0;
        this.type;
        this.message;
        this.fromName = ''; //nickname
        this.cts = timer_1.default.get();
        this.msgId = '';
        this.toAppId = 1; //TODO
        // 扩展信息
        this.extension = '';
        // 序列id
        this.seqId = '0';
        this.retries = 0; //自动重发次数
        this.clusterId = ''; //集群id
        this.receipt = 0; //回执消息
        this.channel = 0;
        this.sessionSeqId = '';
        this.compatible = '';
        this.deviceId = userData_1.default.get('deviceId');
        this.messageReceivedType = constant_1.MESSAGE_RECEIVED_TYPE.CHAT_MESSAGE;
    },
    setUid: function (uid) {
        this.fromUid = uid;
    },
    initAfter: function () {
        this.message && (this.type = this.type || this.message.__type);
    },
    marshall: function () {
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.msgUuid, bufferType_1.default.STRING); //客户端消息ID
        this.push(this.fromUid, bufferType_1.default.LONG);
        this.push(this.toUid, bufferType_1.default.LONG);
        this.push(this.type, bufferType_1.default.INT); //消息类型
        this.push(this.message);
        this.push(this.fromName, bufferType_1.default.STRING);
        this.push(this.cts, bufferType_1.default.LONG);
        this.push(this.msgId, bufferType_1.default.LONG);
        this.push(this.toAppId, bufferType_1.default.SHORT);
        this.push(this.extension, bufferType_1.default.STRING);
        this.push(this.seqId, bufferType_1.default.LONG);
        this.push(this.retries, bufferType_1.default.BYTE);
        this.push(this.clusterId, bufferType_1.default.INT);
        this.push(this.receipt, bufferType_1.default.BYTE);
        this.push(this.channel, bufferType_1.default.SHORT);
        this.push(this.sessionSeqId, bufferType_1.default.LONG);
        this.push(this.compatible, bufferType_1.default.STRING);
        this.push(this.deviceId, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.deviceType = this.popByte(); //1
        this.msgUuid = this.popString(); //2(len)+len
        this.fromUid = this.popLong().value(); //8
        this.toUid = this.popLong().value(); //8
        this.type = this.popInt(); //4
        this.message = protocol_1.default.Message.fromBuffer(this.popBytes()); //2(len)+len
        this.fromName = this.popString(); //2(len)+len
        this.cts = this.popLong().value(); //消息产生时间//8
        this.msgId = this.popLong(); //8
        this.toAppId = this.popShort(); //2
        this.extension = this.popString();
        this.seqId = this.popLong().value();
        this.retries = this.popByte();
        this.clusterId = this.popInt();
        this.receipt = this.popByte();
        this.channel = this.popShort();
        this.sessionSeqId = this.popLong().value();
        this.compatible = this.popString();
        this.deviceId = this.popString();
        var channelMap = userData_1.default.get('channelMap');
        if (channelMap && (!this.channel || this.channel === 0)) {
            if (this.fromUid === userData_1.default.get('uid')) {
                this.channel = channelMap[this.toAppId] || 0;
            }
            else {
                this.channel = channelMap[this.appid] || 0;
            }
        }
    }
});
/**
 * 服务器端消息Res (服务器的Ack)
 * @type {Function}
 */
IMSession.IMSendMsgRes = protocol_1.default.Response.extend({
    category: 'IM',
    uri: im_constant_1.default.IM.URI_IM_SEND_MSG_RES,
    init: function () {
        this.msgUuid = '';
        this.msgId = '';
        this.cts = '';
        this.rescode = 0;
        this.deviceType = deviceInfo_1.default.deviceType;
        this.sessionSeqId = '';
    },
    marshall: function () {
        this.push(this.msgUuid, bufferType_1.default.STRING);
        this.push(this.msgId, bufferType_1.default.LONG);
        this.push(this.cts, bufferType_1.default.LONG);
        this.push(this.rescode, bufferType_1.default.INT);
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.sessionSeqId, bufferType_1.default.LONG);
    },
    unmarshall: function () {
        this.msgUuid = this.popString();
        this.msgId = this.popLong().value();
        this.cts = this.popLong().value();
        this.rescode = this.popInt();
        this.deviceType = this.popByte();
        this.sessionSeqId = this.popLong().value();
    }
});
/**
 * 回服务器端消息Res(Ack)
 * @type {Function}
 */
IMSession.IMAckMsgs = protocol_1.default.Request.extend({
    category: 'IM',
    __master: true,
    init: function () {
        this.uri = im_constant_1.default.IM.URI_IM_ACK_MSGS;
        this.deviceType = deviceInfo_1.default.deviceType;
        this.uid = 0;
        this.msgIds = [];
        this.deviceId = userData_1.default.get('deviceId');
    },
    marshall: function () {
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.uid, bufferType_1.default.LONG);
        this.push(this.msgIds);
        this.push(this.deviceId, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.deviceType = this.popByte();
        this.uid = this.popLong().value();
        this.msgIds = this._popArrayLong();
        this.deviceId = this.popString();
    }
});
/**
 * 回服务器端消息同步Res(Ack)
 * @type {Function}
 */
IMSession.IMAckSyncMsgs = protocol_1.default.Request.extend({
    __master: true,
    category: 'IM',
    init: function () {
        this.uri = im_constant_1.default.IM.URI_IM_ACK_SYNC_MSGS;
        this.deviceType = deviceInfo_1.default.deviceType;
        this.uid = 0;
        this.msgIds = [];
        this.deviceId = userData_1.default.get('deviceId');
    },
    marshall: function () {
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.uid, bufferType_1.default.LONG);
        this.push(this.msgIds);
        this.push(this.deviceId, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.deviceType = this.popByte();
        this.uid = this.popLong().value();
        this.msgIds = this._popArrayLong();
        this.deviceId = this.popString();
    }
});
/**
 * 回服务器端群消息Res(Ack)
 * @type {Function}
 */
IMSession.IMAckGroupMsgs = protocol_1.default.Request.extend({
    __master: true,
    category: 'IM',
    init: function () {
        this.uri = im_constant_1.default.IM.URI_IM_ACK_GROUP_MSGS;
        this.deviceType = deviceInfo_1.default.deviceType;
        this.uid = 0;
        this.msgIds = [];
        this.deviceId = userData_1.default.get('deviceId');
    },
    marshall: function () {
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.uid, bufferType_1.default.LONG);
        this.push(this.msgIds);
        this.push(this.deviceId, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.deviceType = this.popByte();
        this.uid = this.popLong().value();
        this.msgIds = this._popArrayLong();
        this.deviceId = this.popString();
    }
});
/**
 * 回服务器端群消息同步Res(Ack)
 * @type {Function}
 */
IMSession.IMAckSyncGroupMsgs = protocol_1.default.Request.extend({
    __master: true,
    category: 'IM',
    init: function () {
        this.uri = im_constant_1.default.IM.URI_IM_ACK_SYNC_GROUP_MSGS;
        this.deviceType = deviceInfo_1.default.deviceType;
        this.uid = 0;
        this.msgIds = [];
        this.deviceId = userData_1.default.get('deviceId');
    },
    marshall: function () {
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.uid, bufferType_1.default.LONG);
        this.push(this.msgIds);
        this.push(this.deviceId, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.deviceType = this.popByte();
        this.uid = this.popLong().value();
        this.msgIds = this._popArrayLong();
        this.deviceId = this.popString();
    }
});
/**
 * 服务器端已读同步Req
 * @type {Function}
 */
IMSession.IMSyncRead = protocol_1.default.Response.extend({
    category: 'IM',
    uri: im_constant_1.default.IM.URI_IM_SYNC_READ,
    init: function () {
        this.uri = im_constant_1.default.IM.URI_IM_SYNC_READ;
        this.uid = 0;
        this.deviceType = deviceInfo_1.default.deviceType;
        this.syncReadItems = [];
        this.msgUuid = uuid_1.default.next();
        this.deviceId = userData_1.default.get('deviceId');
    },
    marshall: function () {
        this.push(this.uid, bufferType_1.default.LONG);
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.syncReadItems, bufferType_1.default.ARRAY_ARRAY);
        this.push(this.msgUuid, bufferType_1.default.STRING);
        this.push(this.deviceId, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.uid = this.popLong().value();
        this.deviceType = this.popByte();
        var byteItems = this._popArrayArray();
        for (var _i = 0, byteItems_1 = byteItems; _i < byteItems_1.length; _i++) {
            var i = byteItems_1[_i];
            this.syncReadItems.push((new IMSession.IMSyncReadItem().parserFromBuffer(i)));
        }
        this.msgUuid = this.popString();
        this.deviceId = this.popString();
    }
});
/**
 * 服务器端已读同步项
 * @type {Function}
 */
IMSession.IMSyncReadItem = protocol_1.default.Request.extend({
    category: 'IM',
    uri: im_constant_1.default.IM.URI_IM_SYNC_READ_ITEM,
    init: function () {
        this.uri = im_constant_1.default.IM.URI_IM_SYNC_READ_ITEM;
        this.chatId = 0;
        this.stamp = timer_1.default.get();
        this.type = 0;
        this.peerAppId = 0;
        this.sts = 0;
        this.channel = 0;
    },
    marshall: function () {
        this.push(this.chatId, bufferType_1.default.LONG);
        this.push(this.stamp, bufferType_1.default.LONG);
        this.push(this.type, bufferType_1.default.BYTE);
        this.push(this.peerAppId, bufferType_1.default.SHORT);
        this.push(this.sts, bufferType_1.default.LONG);
        this.push(this.channel, bufferType_1.default.SHORT);
    },
    unmarshall: function () {
        this.chatId = this.popLong().value();
        this.stamp = this.popLong().value();
        this.type = this.popByte();
        this.peerAppId = this.popShort();
        this.sts = this.popLong().value();
        this.channel = this.popShort();
    }
});
IMSession.IMSyncReadRes = protocol_1.default.Response.extend({
    category: 'IM',
    uri: im_constant_1.default.IM.URI_IM_SYNC_READ_RES,
    init: function () {
        this.msgUuid = '';
    },
    marshall: function () {
        this.push(this.msgUuid, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.msgUuid = this.popString();
    }
});
//单聊撤销消息
IMSession.IMCancelMsg = protocol_1.default.Response.extend({
    category: 'IM',
    uri: im_constant_1.default.IM.URI_IM_CANCEL_MSG,
    init: function () {
        this.uri = im_constant_1.default.IM.URI_IM_CANCEL_MSG;
        this.deviceType = deviceInfo_1.default.deviceType;
        this.msgUuid = uuid_1.default.next();
        this.fromUid = 0;
        this.toUid = 0;
        this.fromName = ''; //nickname
        this.cts = timer_1.default.get();
        this.msgId = '';
        this.toAppId = 1; //TODO
        // 扩展信息
        this.extension = '';
        this.channel = 0;
        this.isforce = 0;
        this.sts = '';
        this.sessionSeqId = '';
        this.deviceId = userData_1.default.get('deviceId');
        this.messageReceivedType = constant_1.MESSAGE_RECEIVED_TYPE.CANCEL_CHAT_MESSAGE;
    },
    marshall: function () {
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.msgUuid); //客户端消息ID
        this.push(this.fromUid, bufferType_1.default.LONG);
        this.push(this.toUid, bufferType_1.default.LONG);
        this.push(this.fromName);
        this.push(this.cts, bufferType_1.default.LONG);
        this.push(this.msgId, bufferType_1.default.LONG);
        this.push(this.toAppId, bufferType_1.default.SHORT);
        this.push(this.extension);
        this.push(this.channel, bufferType_1.default.SHORT);
        this.push(this.isforce, bufferType_1.default.SHORT);
        this.push(this.sts, bufferType_1.default.LONG);
        this.push(this.sessionSeqId, bufferType_1.default.LONG);
        this.push(this.deviceId, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.deviceType = this.popByte(); //1
        this.msgUuid = this.popString(); //2(len)+len
        this.fromUid = this.popLong().value(); //8
        this.toUid = this.popLong().value(); //8
        this.fromName = this.popString(); //2(len)+len
        this.cts = this.popLong().value(); //消息产生时间//8
        this.msgId = this.popLong(); //8
        this.toAppId = this.popShort(); //2
        this.extension = this.popString();
        this.channel = this.popShort();
        this.isforce = this.popShort();
        this.sts = this.popLong().value();
        this.sessionSeqId = this.popLong().value();
        this.deviceId = this.popString();
    }
});
//单聊撤销消息ACK
IMSession.IMCancelMsgRes = protocol_1.default.Response.extend({
    category: 'IM',
    uri: im_constant_1.default.IM.URI_IM_CANCEL_MSG_RES,
    init: function () {
        this.uri = im_constant_1.default.IM.URI_IM_CANCEL_MSG_RES;
        this.deviceType = deviceInfo_1.default.deviceType;
        this.msgUuid = uuid_1.default.next();
        this.cts = timer_1.default.get();
        this.rescode = 0;
        this.msgId = '';
    },
    marshall: function () {
        this.push(this.msgUuid); //客户端消息ID
        this.push(this.msgId, bufferType_1.default.LONG);
        this.push(this.cts, bufferType_1.default.LONG);
        this.push(this.rescode, bufferType_1.default.INT);
        this.push(this.deviceType, bufferType_1.default.BYTE);
    },
    unmarshall: function () {
        this.msgUuid = this.popString(); //2(len)+len
        this.msgId = this.popLong(); //8
        this.cts = this.popLong().value(); //消息产生时间//8
        this.rescode = this.popInt(); //2(len)+len
        this.deviceType = this.popByte(); //1
    }
});
//群聊撤销消息
IMSession.IMCancelGroupMsg = protocol_1.default.Response.extend({
    category: 'IM',
    uri: im_constant_1.default.IM.URI_IM_CANCEL_GROUP_MSG,
    init: function () {
        this.uri = im_constant_1.default.IM.URI_IM_CANCEL_GROUP_MSG;
        this.deviceType = deviceInfo_1.default.deviceType;
        this.msgUuid = uuid_1.default.next();
        this.fromUid = 0;
        this.toGuid = 0;
        this.fromName = ''; //nickname
        this.groupName = ''; //nickname
        this.cts = timer_1.default.get();
        this.msgId = '';
        this.extension = '';
        this.channel = 0;
        this.isforce = false;
        this.sts = 0;
        this.adminUid = 0; // 撤销管理员uid，0表示普通撤销
        this.sessionSeqId = '';
        this.deviceId = userData_1.default.get('deviceId');
        this.messageReceivedType = constant_1.MESSAGE_RECEIVED_TYPE.CANCEL_GROUP_MESSAGE;
    },
    marshall: function () {
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.msgUuid); //客户端消息ID
        this.push(this.fromUid, bufferType_1.default.LONG);
        this.push(this.toGuid, bufferType_1.default.LONG);
        this.push(this.fromName);
        this.push(this.groupName);
        this.push(this.cts, bufferType_1.default.LONG);
        this.push(this.msgId, bufferType_1.default.LONG);
        this.push(this.extension);
        this.push(this.channel, bufferType_1.default.SHORT);
        this.push(this.isforce, bufferType_1.default.SHORT);
        this.push(this.sts, bufferType_1.default.LONG);
        this.push(this.adminUid, bufferType_1.default.LONG);
        this.push(this.sessionSeqId, bufferType_1.default.LONG);
        this.push(this.deviceId, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.deviceType = this.popByte(); //1
        this.msgUuid = this.popString(); //2(len)+len
        this.fromUid = this.popLong().value(); //8
        this.toGuid = this.popLong().value(); //8
        this.fromName = this.popString(); //2(len)+len
        this.groupName = this.popString(); //2(len)+len
        this.cts = this.popLong().value(); //消息产生时间//8
        this.msgId = this.popLong(); //8
        this.extension = this.popString();
        this.channel = this.popShort();
        this.isforce = this.popShort();
        this.sts = this.popLong().value();
        this.adminUid = this.popLong().value();
        this.sessionSeqId = this.popLong().value();
        this.deviceId = this.popString();
    }
});
//群聊撤销消息ACK
IMSession.IMCancelGroupMsgRes = protocol_1.default.Response.extend({
    category: 'IM',
    uri: im_constant_1.default.IM.URI_IM_CANCEL_GROUP_MSG_RES,
    init: function () {
        this.uri = im_constant_1.default.IM.URI_IM_CANCEL_GROUP_MSG_RES;
        this.deviceType = deviceInfo_1.default.deviceType;
        this.msgUuid = uuid_1.default.next();
        this.cts = timer_1.default.get();
        this.rescode = 0;
        this.msgId = '';
    },
    marshall: function () {
        this.push(this.msgUuid); //客户端消息ID
        this.push(this.msgId, bufferType_1.default.LONG);
        this.push(this.cts, bufferType_1.default.LONG);
        this.push(this.rescode, bufferType_1.default.INT);
        this.push(this.deviceType, bufferType_1.default.BYTE);
    },
    unmarshall: function () {
        this.msgUuid = this.popString(); //2(len)+len
        this.msgId = this.popLong(); //8
        this.cts = this.popLong().value(); //消息产生时间//8
        this.rescode = this.popInt(); //2(len)+len
        this.deviceType = this.popByte(); //1
    }
});
/**
 * 单聊回执消息请求
 */
IMSession.IMReceiptMsgReq = protocol_1.default.Request.extend({
    category: 'IM',
    uri: im_constant_1.default.IM.URI_IM_RECEIPT_MSG_REQ,
    init: function () {
        this.uri = im_constant_1.default.IM.URI_IM_RECEIPT_MSG_REQ;
        this.msgUuid = uuid_1.default.next();
        this.fromUid = 0;
        this.toUid = 0;
        this.msgId = '';
        this.cts = timer_1.default.get();
        this.deviceType = deviceInfo_1.default.deviceType;
        this.channel = 0;
        this.deviceId = userData_1.default.get('deviceId');
    },
    marshall: function () {
        this.push(this.msgUuid);
        this.push(this.fromUid, bufferType_1.default.LONG);
        this.push(this.toUid, bufferType_1.default.LONG);
        this.push(this.msgId, bufferType_1.default.LONG);
        this.push(this.cts, bufferType_1.default.LONG);
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.channel, bufferType_1.default.SHORT);
        this.push(this.deviceId, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.msgUuid = this.popString();
        this.fromUid = this.popLong().value();
        this.toUid = this.popLong().value();
        this.msgId = this.popLong().value();
        this.cts = this.popLong().value();
        this.deviceType = this.popByte();
        this.channel = this.popShort();
        this.deviceId = this.popString();
    }
});
/**
 * 单聊回执消息响应
 */
IMSession.IMReceiptMsgRes = protocol_1.default.Response.extend({
    category: 'IM',
    uri: im_constant_1.default.IM.URI_IM_RECEIPT_MSG_RES,
    init: function () {
        this.uri = im_constant_1.default.IM.URI_IM_RECEIPT_MSG_RES;
        this.msgUuid = uuid_1.default.next();
        this.msgId = '';
        this.cts = timer_1.default.get();
        this.deviceType = deviceInfo_1.default.deviceType;
        this.fromUid = 0;
    },
    marshall: function () {
        this.push(this.msgUuid);
        this.push(this.msgId, bufferType_1.default.LONG);
        this.push(this.cts, bufferType_1.default.LONG);
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.fromUid, bufferType_1.default.LONG);
    },
    unmarshall: function () {
        this.msgUuid = this.popString();
        this.msgId = this.popLong().value();
        this.cts = this.popLong().value();
        this.deviceType = this.popByte();
        this.fromUid = this.popLong().value();
    }
});
/**
 * 群聊回执消息请求
 */
IMSession.IMReceiptGroupMsgReq = protocol_1.default.Request.extend({
    category: 'IM',
    uri: im_constant_1.default.IM.URI_IM_RECEIPT_GROUP_MSG_REQ,
    init: function () {
        this.uri = im_constant_1.default.IM.URI_IM_RECEIPT_GROUP_MSG_REQ;
        this.msgUuid = uuid_1.default.next();
        this.fromUid = 0;
        this.toGuid = 0;
        this.toUid = 0;
        this.msgId = '';
        this.cts = timer_1.default.get();
        this.deviceType = deviceInfo_1.default.deviceType;
        this.channel = 0;
        this.deviceId = userData_1.default.get('deviceId');
    },
    marshall: function () {
        this.push(this.msgUuid);
        this.push(this.fromUid, bufferType_1.default.LONG);
        this.push(this.toGuid, bufferType_1.default.LONG);
        this.push(this.toUid, bufferType_1.default.LONG);
        this.push(this.msgId, bufferType_1.default.LONG);
        this.push(this.cts, bufferType_1.default.LONG);
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.channel, bufferType_1.default.SHORT);
        this.push(this.deviceId, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.msgUuid = this.popString();
        this.fromUid = this.popLong().value();
        this.toGuid = this.popLong().value();
        this.toUid = this.popLong().value();
        this.msgId = this.popLong().value();
        this.cts = this.popLong().value();
        this.deviceType = this.popByte();
        this.channel = this.popShort();
        this.deviceId = this.popString();
    }
});
/**
 * 群聊回执消息响应
 */
IMSession.IMReceiptGroupMsgRes = protocol_1.default.Response.extend({
    category: 'IM',
    uri: im_constant_1.default.IM.URI_IM_RECEIPT_GROUP_MSG_RES,
    init: function () {
        this.uri = im_constant_1.default.IM.URI_IM_RECEIPT_GROUP_MSG_RES;
        this.msgUuid = uuid_1.default.next();
        this.msgId = '';
        this.cts = timer_1.default.get();
        this.fromUid = 0;
        this.deviceType = deviceInfo_1.default.deviceType;
    },
    marshall: function () {
        this.push(this.msgUuid);
        this.push(this.msgId, bufferType_1.default.LONG);
        this.push(this.cts, bufferType_1.default.LONG);
        this.push(this.fromUid, bufferType_1.default.LONG);
        this.push(this.deviceType, bufferType_1.default.BYTE);
    },
    unmarshall: function () {
        this.msgUuid = this.popString();
        this.msgId = this.popLong().value();
        this.cts = this.popLong().value();
        this.fromUid = this.popLong().value();
        this.deviceType = this.popByte();
    }
});
IMSession.IMMarkReads = protocol_1.default.Response.extend({
    category: 'IM',
    uri: im_constant_1.default.IM.URI_IM_MARK_READS,
    init: function () {
        this.uri = im_constant_1.default.IM.URI_IM_MARK_READS;
        this.uid = '';
        this.deviceType = deviceInfo_1.default.deviceType;
        this.markReads = [];
    },
    marshall: function () {
        this.push(this.uid, bufferType_1.default.LONG);
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.markReads, bufferType_1.default.BYTES);
    },
    unmarshall: function () {
        this.uid = this.popLong().value();
        this.deviceType = this.popByte();
        var byteItems = this._popArrayArray();
        for (var _i = 0, byteItems_2 = byteItems; _i < byteItems_2.length; _i++) {
            var i = byteItems_2[_i];
            this.markReads.push((new IMSession.IMMarkRead().parserFromBuffer(i)));
        }
    }
});
/**
 * 标记已读未读消息
 */
IMSession.IMMarkRead = protocol_1.default.Response.extend({
    category: 'IM',
    uri: im_constant_1.default.IM.URI_IM_MARK_READ,
    init: function () {
        this.uri = im_constant_1.default.IM.URI_IM_MARK_READ;
        this.chatId = 0;
        this.chatType = 0;
        this.chatAppId = 0;
        this.opt = 1;
        this.channel = 0;
    },
    marshall: function () {
        this.push(this.chatId, bufferType_1.default.LONG);
        this.push(this.chatType, bufferType_1.default.BYTE);
        this.push(this.chatAppId, bufferType_1.default.SHORT);
        this.push(this.opt, bufferType_1.default.BYTE);
        this.push(this.channel, bufferType_1.default.SHORT);
    },
    unmarshall: function () {
        this.chatId = this.popLong().value();
        this.chatType = this.popByte();
        this.chatAppId = this.popShort();
        this.opt = this.popByte();
        this.channel = this.popShort();
    }
});
IMSession.IMOppositeSyncRead = protocol_1.default.Response.extend({
    category: 'IM',
    uri: im_constant_1.default.IM.URI_IM_OPPOSITE_SYNC2_READ,
    init: function () {
        this.uid = '';
        this.msgUuid = uuid_1.default.next();
        this.deviceType = deviceInfo_1.default.deviceType;
        this.syncReadItems = [];
        this.deviceId = userData_1.default.get('deviceId');
    },
    marshall: function () {
        this.push(this.uid, bufferType_1.default.LONG);
        this.push(this.msgUuid, bufferType_1.default.STRING);
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.syncReadItems, bufferType_1.default.ARRAY_ARRAY);
        this.push(this.deviceId, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.uid = this.popLong().value();
        this.msgUuid = this.popString();
        this.deviceType = this.popByte();
        var byteItems = this._popArrayArray();
        for (var _i = 0, byteItems_3 = byteItems; _i < byteItems_3.length; _i++) {
            var i = byteItems_3[_i];
            this.syncReadItems.push((new IMSession.IMOppositeSyncReadItem().parserFromBuffer(i)));
        }
        this.deviceId = this.popString();
    }
});
IMSession.IMOppositeSyncReadItem = protocol_1.default.Response.extend({
    category: 'IM',
    uri: im_constant_1.default.IM.URI_IM_OPPOSITE_SYNC2_READ_ITEM,
    init: function () {
        this.chatId = '';
        this.type = 0; // 单聊：1
        this.peerAppId = 0;
        this.channel = 0;
        this.msgIds = [];
    },
    marshall: function () {
        this.push(this.chatId, bufferType_1.default.LONG);
        this.push(this.type, bufferType_1.default.BYTE);
        this.push(this.peerAppId, bufferType_1.default.SHORT);
        this.push(this.channel, bufferType_1.default.SHORT);
        this.push(this.msgIds, bufferType_1.default.ARRAY_LONG);
    },
    unmarshall: function () {
        this.chatId = this.popLong().value();
        this.type = this.popByte();
        this.peerAppId = this.popShort();
        this.channel = this.popShort();
        this.msgIds = this._popArrayLong();
    }
});
IMSession.IMOppositeSyncReadRes = protocol_1.default.Response.extend({
    category: 'IM',
    uri: im_constant_1.default.IM.URI_IM_OPPOSITE_SYNC2_READ_RES,
    init: function () {
        this.uid = '';
        this.msgUuid = '';
        this.deviceType = '';
    },
    marshall: function () {
        this.push(this.uid, bufferType_1.default.LONG);
        this.push(this.msgUuid, bufferType_1.default.STRING);
        this.push(this.deviceType, bufferType_1.default.BYTE);
    },
    unmarshall: function () {
        this.uid = this.popLong().value();
        this.msgUuid = this.popString();
        this.deviceType = this.popByte();
    }
});
IMSession.IMReceiptGroupMsgs = protocol_1.default.Response.extend({
    category: 'IM',
    uri: im_constant_1.default.IM.URI_IM_RECEIPT_GROUP_MSGS,
    init: function () {
        this.receiptUuid = uuid_1.default.next();
        this.fromUid = '';
        this.toGuid = '';
        this.cts = timer_1.default.get();
        this.deviceType = deviceInfo_1.default.deviceType;
        this.channel = 0;
        this.items = [];
        this.deviceId = userData_1.default.get('deviceId');
    },
    marshall: function () {
        this.push(this.receiptUuid, bufferType_1.default.STRING);
        this.push(this.fromUid, bufferType_1.default.LONG);
        this.push(this.toGuid, bufferType_1.default.LONG);
        this.push(this.cts, bufferType_1.default.LONG);
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.channel, bufferType_1.default.SHORT);
        this.push(this.items, bufferType_1.default.ARRAY_ARRAY);
        this.push(this.deviceId, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.receiptUuid = this.popString();
        this.fromUid = this.popLong().value();
        this.toGuid = this.popLong().value();
        this.cts = this.popLong().value();
        this.deviceType = this.popByte();
        this.channel = this.popShort();
        this.items = [];
        var byteItems = this._popArrayArray();
        for (var _i = 0, byteItems_4 = byteItems; _i < byteItems_4.length; _i++) {
            var i = byteItems_4[_i];
            this.items.push((new IMSession.IMReceiptGroupItem().parserFromBuffer(i)));
        }
        this.deviceId = this.popString();
    }
});
IMSession.IMReceiptGroupItem = protocol_1.default.Response.extend({
    category: 'IM',
    uri: im_constant_1.default.IM.URI_IM_RECEIPT_GROUP_ITEM,
    init: function () {
        this.msgUuid = '';
        // 原消息发送者 uid
        this.toUid = '';
        this.msgId = '';
    },
    marshall: function () {
        this.push(this.msgUuid, bufferType_1.default.STRING);
        this.push(this.toUid, bufferType_1.default.LONG);
        this.push(this.msgId, bufferType_1.default.LONG);
    },
    unmarshall: function () {
        this.msgUuid = this.popString();
        this.toUid = this.popLong().value();
        this.msgId = this.popLong().value();
    }
});
IMSession.IMReceiptGroupMsgsRes = protocol_1.default.Response.extend({
    category: 'IM',
    uri: im_constant_1.default.IM.URI_IM_RECEIPT_GROUP_MSGS_RES,
    init: function () {
        this.receiptUuid = uuid_1.default.next();
        this.cts = 0;
        this.deviceType = 0;
        this.fromUid = '';
        this.items = [];
    },
    marshall: function () {
        this.push(this.receiptUuid, bufferType_1.default.STRING);
        this.push(this.cts.bt.LONG);
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.fromUid, bufferType_1.default.LONG);
        this.push(this.items, bufferType_1.default.ARRAY_ARRAY);
    },
    unmarshall: function () {
        this.receiptUuid = this.popString();
        this.cts = this.popLong().value();
        this.deviceType = this.popByte();
        this.fromUid = this.popLong().value();
        this.items = [];
        var byteItems = this._popArrayArray();
        for (var _i = 0, byteItems_5 = byteItems; _i < byteItems_5.length; _i++) {
            var i = byteItems_5[_i];
            this.items.push((new IMSession.IMReceiptGroupItem().parserFromBuffer(i)));
        }
    }
});
IMSession.IMReceiptGroupMsgsRecv = protocol_1.default.Response.extend({
    category: 'IM',
    uri: im_constant_1.default.IM.URI_IM_RECEIPT_GROUP_MSGS_RECV,
    init: function () {
        this.receiptUuid = uuid_1.default.next();
        this.fromUid = '';
        this.toGuid = '';
        this.cts = 0;
        this.deviceType = deviceInfo_1.default.deviceType;
        this.channel = 0;
        this.items = [];
    },
    marshall: function () {
        this.push(this.receiptUuid, bufferType_1.default.STRING);
        this.push(this.fromUid, bufferType_1.default.LONG);
        this.push(this.toGuid, bufferType_1.default.LONG);
        this.push(this.cts, bufferType_1.default.LONG);
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.channel, bufferType_1.default.SHORT);
        this.push(this.items, bufferType_1.default.ARRAY_ARRAY);
    },
    unmarshall: function () {
        this.receiptUuid = this.popString();
        this.fromUid = this.popLong().value();
        this.toGuid = this.popLong().value();
        this.cts = this.popLong().value();
        this.deviceType = this.popByte();
        this.channel = this.popShort();
        this.items = [];
        var byteItems = this._popArrayArray();
        for (var _i = 0, byteItems_6 = byteItems; _i < byteItems_6.length; _i++) {
            var i = byteItems_6[_i];
            this.items.push((new IMSession.IMReceiptGroupItem().parserFromBuffer(i)));
        }
    }
});
IMSession.IMCancelMsg2 = protocol_1.default.Response.extend({
    category: 'IM',
    uri: im_constant_1.default.IM.URI_IM_CANCEL_MSG2,
    init: function () {
        this.uri = im_constant_1.default.IM.URI_IM_CANCEL_MSG2;
        this.version = 2;
        this.deviceType = deviceInfo_1.default.deviceType;
        this.msgUuid = uuid_1.default.next();
        this.fromUid = 0;
        this.toUid = 0;
        this.fromName = ''; //nickname
        this.cts = timer_1.default.get();
        this.msgId = '';
        this.toAppId = 1; //TODO
        // 扩展信息
        this.extension = '';
        this.channel = 0;
        this.isforce = 0;
        this.sts = '';
        this.sessionSeqId = '';
        this.deviceId = userData_1.default.get('deviceId');
        this.sid = '';
        this.messageReceivedType = constant_1.MESSAGE_RECEIVED_TYPE.CANCEL_CHAT_MESSAGE2;
    },
    marshall: function () {
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.msgUuid, bufferType_1.default.STRING);
        this.push(this.fromUid, bufferType_1.default.LONG);
        this.push(this.toUid, bufferType_1.default.LONG);
        this.push(this.fromName, bufferType_1.default.STRING);
        this.push(this.cts, bufferType_1.default.LONG);
        this.push(this.msgId, bufferType_1.default.LONG);
        this.push(this.toAppId, bufferType_1.default.SHORT);
        this.push(this.extension, bufferType_1.default.STRING);
        this.push(this.channel, bufferType_1.default.SHORT);
        this.push(this.isforce, bufferType_1.default.SHORT);
        this.push(this.sts, bufferType_1.default.LONG);
        this.push(this.sessionSeqId, bufferType_1.default.LONG);
        this.push(this.deviceId, bufferType_1.default.STRING);
        this.push(this.sid, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.deviceType = this.popByte();
        this.msgUuid = this.popString();
        this.fromUid = this.popLong().value();
        this.toUid = this.popLong().value();
        this.fromName = this.popString();
        this.ctx = this.popLong().value();
        this.msgId = this.popLong().value();
        this.toAppId = this.popShort();
        this.extension = this.popString();
        this.channel = this.popShort();
        this.isforce = this.popShort();
        this.sts = this.popLong().value();
        this.sessionSeqId = this.popLong().value();
        this.deviceId = this.popString();
        this.sid = this.popString();
    }
});
IMSession.IMOppositeSyncRead2 = protocol_1.default.Response.extend({
    category: 'IM',
    uri: im_constant_1.default.IM.URI_IM_OPPOSITE_SYNC2_READ2,
    init: function () {
        this.uri = im_constant_1.default.IM.URI_IM_OPPOSITE_SYNC2_READ2;
        this.version = 2;
        this.uid = '';
        this.msgUuid = uuid_1.default.next();
        this.deviceType = deviceInfo_1.default.deviceType;
        this.syncReadItems = [];
        this.deviceId = userData_1.default.get('deviceId');
    },
    marshall: function () {
        this.push(this.uid, bufferType_1.default.LONG);
        this.push(this.msgUuid, bufferType_1.default.STRING);
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.syncReadItems, bufferType_1.default.ARRAY_ARRAY);
        this.push(this.deviceId, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.uid = this.popLong().value();
        this.msgUuid = this.popString();
        this.deviceType = this.popByte();
        var byteItems = this._popArrayArray();
        for (var _i = 0, byteItems_7 = byteItems; _i < byteItems_7.length; _i++) {
            var i = byteItems_7[_i];
            this.syncReadItems.push((new IMSession.IMOppositeSyncReadItem2().parserFromBuffer(i)));
        }
        this.deviceId = this.popString();
    }
});
IMSession.IMOppositeSyncReadItem2 = protocol_1.default.Response.extend({
    category: 'IM',
    uri: im_constant_1.default.IM.URI_IM_OPPOSITE_SYNC2_READ_ITEM2,
    init: function () {
        this.uri = im_constant_1.default.IM.URI_IM_OPPOSITE_SYNC2_READ_ITEM2;
        this.version = 2;
        // uid
        this.chatId = 0;
        // Chat Type
        this.type = 0;
        // chat target appid
        this.peerAppId = 0;
        // 频道
        this.channel = 0;
        // 消息ID
        this.msgIds = [];
        // 自定义会话
        this.sid = '';
    },
    marshall: function () {
        this.push(this.chatId, bufferType_1.default.LONG);
        this.push(this.type, bufferType_1.default.BYTE);
        this.push(this.peerAppId, bufferType_1.default.SHORT);
        this.push(this.channel, bufferType_1.default.SHORT);
        this.push(this.msgIds);
        this.push(this.sid, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.chatId = this.popLong().value();
        this.type = this.popByte();
        this.peerAppId = this.popShort();
        this.channel = this.popShort();
        this.msgIds = this._popArrayLong();
        this.sid = this.popString();
    }
});
IMSession.IMSendMsg2 = protocol_1.default.Response.extend({
    category: 'IM',
    uri: im_constant_1.default.IM.URI_IM_SEND_MSG2,
    init: function () {
        this.uri = im_constant_1.default.IM.URI_IM_SEND_MSG2;
        this.version = 2;
        this.deviceType = deviceInfo_1.default.deviceType;
        this.msgUuid = uuid_1.default.next();
        this.fromUid = 0;
        this.toUid = 0;
        this.type;
        this.message;
        this.fromName = ''; //nickname
        this.cts = timer_1.default.get();
        this.msgId = '';
        this.toAppId = 1; //TODO
        // 扩展信息
        this.extension = '';
        // 序列id
        this.seqId = '0';
        this.retries = 0; //自动重发次数
        this.clusterId = ''; //集群id
        this.receipt = 0; //回执消息
        this.channel = 0;
        this.sessionSeqId = '';
        this.compatible = '';
        this.deviceId = userData_1.default.get('deviceId');
        this.sid = '';
        this.messageReceivedType = constant_1.MESSAGE_RECEIVED_TYPE.CHAT_MESSAGE2;
    },
    setUid: function (uid) {
        this.fromUid = uid;
    },
    initAfter: function () {
        this.message && (this.type = this.type || this.message.__type);
    },
    marshall: function () {
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.msgUuid, bufferType_1.default.STRING); //客户端消息ID
        this.push(this.fromUid, bufferType_1.default.LONG);
        this.push(this.toUid, bufferType_1.default.LONG);
        this.push(this.type, bufferType_1.default.INT); //消息类型
        this.push(this.message);
        this.push(this.fromName, bufferType_1.default.STRING);
        this.push(this.cts, bufferType_1.default.LONG);
        this.push(this.msgId, bufferType_1.default.LONG);
        this.push(this.toAppId, bufferType_1.default.SHORT);
        this.push(this.extension, bufferType_1.default.STRING);
        this.push(this.seqId, bufferType_1.default.LONG);
        this.push(this.retries, bufferType_1.default.BYTE);
        this.push(this.clusterId, bufferType_1.default.INT);
        this.push(this.receipt, bufferType_1.default.BYTE);
        this.push(this.channel, bufferType_1.default.SHORT);
        this.push(this.sessionSeqId, bufferType_1.default.LONG);
        this.push(this.compatible, bufferType_1.default.STRING);
        this.push(this.deviceId, bufferType_1.default.STRING);
        this.push(this.sid, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.deviceType = this.popByte(); //1
        this.msgUuid = this.popString(); //2(len)+len
        this.fromUid = this.popLong().value(); //8
        this.toUid = this.popLong().value(); //8
        this.type = this.popInt(); //4
        this.message = protocol_1.default.Message.fromBuffer(this.popBytes()); //2(len)+len
        this.fromName = this.popString(); //2(len)+len
        this.cts = this.popLong().value(); //消息产生时间//8
        this.msgId = this.popLong(); //8
        this.toAppId = this.popShort(); //2
        this.extension = this.popString();
        this.seqId = this.popLong().value();
        this.retries = this.popByte();
        this.clusterId = this.popInt();
        this.receipt = this.popByte();
        this.channel = this.popShort();
        this.sessionSeqId = this.popLong().value();
        this.compatible = this.popString();
        this.deviceId = this.popString();
        this.sid = this.popString();
        var channelMap = userData_1.default.get('channelMap');
        if (channelMap && (!this.channel || this.channel === 0)) {
            if (this.fromUid === userData_1.default.get('uid')) {
                this.channel = channelMap[this.toAppId] || 0;
            }
            else {
                this.channel = channelMap[this.appid] || 0;
            }
        }
    }
});
IMSession.IMSyncRead2 = protocol_1.default.Response.extend({
    category: 'IM',
    uri: im_constant_1.default.IM.URI_IM_SYNC_READ2,
    init: function () {
        this.uri = im_constant_1.default.IM.URI_IM_SYNC_READ2;
        this.version = 2;
        this.uid = 0;
        this.deviceType = deviceInfo_1.default.deviceType;
        this.syncReadItems = [];
        this.msgUuid = uuid_1.default.next();
        this.deviceId = userData_1.default.get('deviceId');
    },
    marshall: function () {
        this.push(this.uid, bufferType_1.default.LONG);
        this.push(this.deviceType, bufferType_1.default.BYTE);
        this.push(this.syncReadItems, bufferType_1.default.ARRAY_ARRAY);
        this.push(this.msgUuid, bufferType_1.default.STRING);
        this.push(this.deviceId, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.uid = this.popLong().value();
        this.deviceType = this.popByte();
        var byteItems = this._popArrayArray();
        for (var _i = 0, byteItems_8 = byteItems; _i < byteItems_8.length; _i++) {
            var i = byteItems_8[_i];
            this.syncReadItems.push((new IMSession.IMSyncReadItem2().parserFromBuffer(i)));
        }
        this.msgUuid = this.popString();
        this.deviceId = this.popString();
    }
});
IMSession.IMSyncReadItem2 = protocol_1.default.Request.extend({
    category: 'IM',
    uri: im_constant_1.default.IM.URI_IM_SYNC_READ_ITEM2,
    init: function () {
        this.uri = im_constant_1.default.IM.URI_IM_SYNC_READ_ITEM2;
        this.version = 2;
        this.chatId = 0;
        this.stamp = timer_1.default.get();
        this.type = 0;
        this.peerAppId = 0;
        this.sts = 0;
        this.channel = 0;
        this.sid = '';
    },
    marshall: function () {
        this.push(this.chatId, bufferType_1.default.LONG);
        this.push(this.stamp, bufferType_1.default.LONG);
        this.push(this.type, bufferType_1.default.BYTE);
        this.push(this.peerAppId, bufferType_1.default.SHORT);
        this.push(this.sts, bufferType_1.default.LONG);
        this.push(this.channel, bufferType_1.default.SHORT);
        this.push(this.sid, bufferType_1.default.STRING);
    },
    unmarshall: function () {
        this.chatId = this.popLong().value();
        this.stamp = this.popLong().value();
        this.type = this.popByte();
        this.peerAppId = this.popShort();
        this.sts = this.popLong().value();
        this.channel = this.popShort();
        this.sid = this.popString();
    }
});
IMSession.IMPersonMessageAddition2 = protocol_1.default.Response.extend({
    category: 'IM',
    uri: im_constant_1.default.IM.URI_IM_PERSON_ADDITION_MSG2,
    init: function () {
        this.version = 2;
        this.msgUuid = '';
        this.fromUid = '';
        this.deviceType = deviceInfo_1.default.deviceType;
        this.deviceId = userData_1.default.get('deviceId');
        this.msgId = '';
        this.channel = 0;
        this.additionData = '';
        this.receivers = {};
        this.sts = '';
        this.seqId = 0;
        this.allowAddition = false;
    },
    unmarshall: function () {
        this.msgUuid = this.popString();
        this.fromUid = this.popLong().value();
        this.deviceType = this.popByte();
        this.deviceId = this.popString();
        this.msgId = this.popLong().value();
        this.channel = this.popShort();
        this.additionData = this.popString();
        this.receivers = this.popMapOfLongAndShort();
        this.sts = this.popLong().value();
        this.seqId = this.popInt();
        this.allowAddition = this.popBool();
    }
});
IMSession.IMGroupMessageAddition2 = protocol_1.default.Response.extend({
    category: 'IM',
    uri: im_constant_1.default.IM.URI_IM_GROUP_ADDITION_MSG2,
    init: function () {
        this.version = 2;
        this.msgUuid = '';
        this.fromUid = '';
        this.deviceType = deviceInfo_1.default.deviceType;
        this.deviceId = userData_1.default.get('deviceId');
        this.msgId = '';
        this.channel = 0;
        this.additionData = '';
        this.guid = '';
        this.receivers = [];
        this.receiverAppId = '';
        this.sts = '';
        this.seqId = 0;
        this.allowAddition = false;
    },
    unmarshall: function () {
        this.msgUuid = this.popString();
        this.fromUid = this.popLong().value();
        this.deviceType = this.popByte();
        this.deviceId = this.popString();
        this.msgId = this.popLong().value();
        this.channel = this.popShort();
        this.additionData = this.popString();
        this.guid = this.popLong().value();
        this.receivers = this._popArrayLong();
        this.receiverAppId = this.popShort();
        this.sts = this.popLong().value();
        this.seqId = this.popInt();
        this.allowAddition = this.popBool();
    }
});
exports.default = IMSession;


//# sourceURL=webpack://MTDX/./src/core/im/im.session.ts?